package org.xteam.sled.semantic.exp;

public class ExpMul extends ExpFactor {

	public ExpMul(int value, Exp expr) {
		super(value, expr);
	}
	
	public int hashCode() {
		return expr.hashCode() + factor;
	}
	
	public boolean equals(Object o) {
		return (o instanceof ExpMul)
			&& ((ExpMul)o).factor == factor
			&& ((ExpMul)o).expr.equals(expr);
	}
	
	protected TermList toTermList(boolean neg, TermList answers) {
		if (factor != 0)
			answers.add(neg ? -factor : factor, expr);
		return answers;
	}

	@Override
	public void visit(IExpVisitor visitor) {
		visitor.visitMul(this);
	}
	
	public String toString() {
		return "(" + factor + " * " + expr + ")";
	}
	
}
